package au.com.handsunited.motherofalldaos.dao;

import java.util.List;

import au.com.handsunited.paginationutils.Order;
import au.com.handsunited.paginationutils.Page;

/**
 * @author Arun Chandrasekhar
 */
public interface BaseDao<T> {

	String SORTORDER_ASCENDING = "asc";
	String SORTORDER_DESCENDING = "desc";

	/**
	 * @param newInstance
	 * @return
	 */
	T create(T newInstance);

	/**
	 * @param id
	 * @return
	 */
	T read(Long id);

	/**
	 * @param transientObject
	 * @return
	 */
	T update(T transientObject);

	/**
	 * @param persistentObject
	 */
	void delete(T persistentObject);

	/**
	 * @return
	 */
	Page<T> findAll();

	/**
	 * @param pageNumber
	 * @param pageSize
	 * @return
	 */
	Page<T> findAll(int pageNumber, int pageSize);

	/**
	 * @param orderBy
	 * @return
	 */
	Page<T> findAll(Order orderBy);

	/**
	 * @param orderBy
	 * @param pageNumber
	 * @param pageSize
	 * @return
	 */
	Page<T> findAll(Order orderBy, int pageNumber, int pageSize);

	/**
	 * @param orderByClause
	 * @return
	 */
	Page<T> findAll(List<Order> orderByClause);

	/**
	 * @param example
	 * @return
	 */
	Page<T> findByExample(T example);

	/**
	 * @param example
	 * @param pageNumber
	 * @param pageSize
	 * @return
	 */
	Page<T> findByExample(T example, int pageNumber, int pageSize);

	/**
	 * @param example
	 * @param order
	 * @param pageNumber
	 * @param pageSize
	 * @return
	 */
	Page<T> findByExample(T example, Order order, int pageNumber, int pageSize);

	/**
	 * @param exampleInstance
	 * @param excludeProperty
	 * @return
	 */
	Page<T> findByExample(T exampleInstance, String[] excludeProperty);

	/**
	 * @param exampleInstance
	 * @param excludeProperty
	 * @param pageNumber
	 * @param pageSize
	 * @return
	 */
	Page<T> findByExample(T exampleInstance, String[] excludeProperty,
			int pageNumber, int pageSize);

	/**
	 * @param exampleInstance
	 * @param excludeProperty
	 * @param orderByClause
	 * @return
	 */
	Page<T> findByExample(T exampleInstance, String[] excludeProperty,
			List<Order> orderByClause);

	/**
	 * @param exampleInstance
	 * @param excludeProperty
	 * @param orderByClause
	 * @param pageNumber
	 * @param pageSize
	 * @return
	 */
	Page<T> findByExample(T exampleInstance, String[] excludeProperty,
			List<Order> orderByClause, int pageNumber, int pageSize);

}
